/*
 * @Description: object
 * @Author: rendc
 * @Date: 2022-09-27 09:58:17
 * @LastEditors: rendc
 * @LastEditTime: 2022-09-27 10:18:55
 */
let person = {
  name: "张三",
  age: 24,
  like: {},
  book: [1, 3, 5],
  sayHello: function () {
    console.log(this.name + ":hello,world");
  }
}
console.log(person.name);
console.log(person["age"]);
person.sayHello();
var person2 = new Object();
// 新增或修改属性
person2.name = "李四";
// 删除属性
person2.age = 25;
delete person2.age
person2.sayHello = function () {
  console.log(this.name + ":hello, world");
}
console.log('🤡 CC - person2', person2);
person2.sayHello();
// json
let person3 = {
  name: "王五",
  age: 24,
  book: [1, 3, 5],
}
console.log('🤡 CC - person3', person3);
// 将对象转为字符串
let person3Str = JSON.stringify(person3);
console.log('🤡 CC - person3Str', person3Str);
// 后台给我们的数据就是这个样子
let person3Http = '{"name":"王五","age":24,"book":[1,3,5]}'
let person3Obj = JSON.parse(person3Http);
console.log('🤡 CC - person3Obj', person3Obj);
